using System;
using NUnit.Framework;
using dnAnalytics.Math;
using dnAnalytics.UnitTests;
namespace dnAnalytics.UnitTests.Math
{
	[TestFixture]
	[Category("Managed")]
	public class ComplexMath_AbsoluteTest
	{
		[Test]
		public void Absolute()
		{
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,1.19209289550780998537e-7)), 1.19209289550780998537e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,-1.19209289550780998537e-7)), 1.19209289550780998537e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,5.0e-1)), 5.0e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,-5.0e-1)), 5.0e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,1.0)), 1.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,-1.0)), 1.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,2.0)), 2.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,-2.0)), 2.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,8.388608e6)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(0.0,-8.388608e6)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,0.0)), 1.19209289550780998537e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,0.0)), 1.19209289550780998537e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,1.19209289550780998537e-7)), 1.68587394043575771526e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,-1.19209289550780998537e-7)), 1.68587394043575771526e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,1.19209289550780998537e-7)), 1.68587394043575771526e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,-1.19209289550780998537e-7)), 1.68587394043575771526e-7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,5.0e-1)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,-5.0e-1)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,5.0e-1)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,-5.0e-1)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,1.0)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,-1.0)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,1.0)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,-1.0)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,2.0)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,-2.0)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,2.0)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,-2.0)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,8.388608e6)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.19209289550780998537e-7,-8.388608e6)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,8.388608e6)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.19209289550780998537e-7,-8.388608e6)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,0.0)), 5.0e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,0.0)), 5.0e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,1.19209289550780998537e-7)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,-1.19209289550780998537e-7)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,1.19209289550780998537e-7)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,-1.19209289550780998537e-7)), 5.00000000000014210855e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,5.0e-1)), 7.07106781186547524401e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,-5.0e-1)), 7.07106781186547524401e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,5.0e-1)), 7.07106781186547524401e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,-5.0e-1)), 7.07106781186547524401e-1, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,1.0)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,-1.0)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,1.0)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,-1.0)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,2.0)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,-2.0)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,2.0)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,-2.0)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,8.388608e6)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(5.0e-1,-8.388608e6)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,8.388608e6)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-5.0e-1,-8.388608e6)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,0.0)), 1.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,0.0)), 1.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,1.19209289550780998537e-7)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,-1.19209289550780998537e-7)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,1.19209289550780998537e-7)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,-1.19209289550780998537e-7)), 1.00000000000000710543, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,5.0e-1)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,-5.0e-1)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,5.0e-1)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,-5.0e-1)), 1.1180339887498948482, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,1.0)), 1.4142135623730950488, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,-1.0)), 1.4142135623730950488, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,1.0)), 1.4142135623730950488, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,-1.0)), 1.4142135623730950488, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,2.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,-2.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,2.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,-2.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,8.388608e6)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(1.0,-8.388608e6)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,8.388608e6)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-1.0,-8.388608e6)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,0.0)), 2.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,0.0)), 2.0, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,1.19209289550780998537e-7)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,-1.19209289550780998537e-7)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,1.19209289550780998537e-7)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,-1.19209289550780998537e-7)), 2.00000000000000355271, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,5.0e-1)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,-5.0e-1)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,5.0e-1)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,-5.0e-1)), 2.06155281280883027491, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,1.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,-1.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,1.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,-1.0)), 2.23606797749978969641, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,2.0)), 2.8284271247461900976, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,-2.0)), 2.8284271247461900976, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,2.0)), 2.8284271247461900976, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,-2.0)), 2.8284271247461900976, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,8.388608e6)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(2.0,-8.388608e6)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,8.388608e6)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-2.0,-8.388608e6)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,0.0)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,0.0)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,1.19209289550780998537e-7)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,-1.19209289550780998537e-7)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,1.19209289550780998537e-7)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,-1.19209289550780998537e-7)), 8.388608e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,5.0e-1)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,-5.0e-1)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,5.0e-1)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,-5.0e-1)), 8.38860800000001490116e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,1.0)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,-1.0)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,1.0)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,-1.0)), 8.38860800000005960464e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,2.0)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,-2.0)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,2.0)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,-2.0)), 8.38860800000023841858e6, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,8.388608e6)), 1.18632832030314441111e7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(8.388608e6,-8.388608e6)), 1.18632832030314441111e7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,8.388608e6)), 1.18632832030314441111e7, 2e-016);
			TestHelper.TestRelativeError(ComplexMath.Absolute(new Complex(-8.388608e6,-8.388608e6)), 1.18632832030314441111e7, 2e-016);
		}
	}
}
